3 struct MapBlockers: View {
7 let blockers: [Blocker]
9 let cornerSize = CGSize(width: 2.0, height: 2.0)
12 ForEach(blockers, id: \.id) { vertex in
17 x: w(vertex.position.x) + 3 * vertexSize.width,
18 y: h(vertex.position.y) - vertexSize.height * 2 / 3),
19 size: CGSize(width: vertexSize.width / 2, height: vertexSize.height * 2)
20 ), cornerSize: cornerSize)
21 }.fill(Color.map.blockerColor)
25 func h(_ dimension: CGFloat) -> CGFloat {
26 max(0.0, min(mapSize.height, dimension * mapSize.height / 100.0))
29 func w(_ dimension: CGFloat) -> CGFloat {
30 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
36 mapSize: CGSize(width: 400.0, height: 400.0), vertexSize: CGSize(width: 25.0, height: 25.0),
38 Blocker(id: 0, position: CGPoint(x: 50.0, y: 50.0)),
39 Blocker(id: 1, position: CGPoint(x: 10.0, y: 20.0)),